package fms.models;
 
import java.util.List;
 
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import fms.classes.BookkeepersLiquidationRegister;
 
 
public class BookkeepersLiquidationRegisterDAO {
 
    private SqlSessionFactory sqlSessionFactory;
 
    public BookkeepersLiquidationRegisterDAO(){
    	try{
    		sqlSessionFactory = MyBatisSqlConnection.getSqlSessionFactory();
    	}catch(Exception e) {
    		System.out.println("failed to get sqlSessionFactory");
    	}
    }
 
    /**Returns the list of all BookkeepersLiquidationRegister instances from the database*/
    @SuppressWarnings("unchecked")
    public List<BookkeepersLiquidationRegister> selectAll(){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            List<BookkeepersLiquidationRegister> list = session.selectList("BookkeepersLiquidationRegister.getAll");
            return list;
        } finally {
            session.close();
        }
    }
 
    /**Returns a BookkeepersLiquidationRegister instance from the database*/
    public BookkeepersLiquidationRegister selectById(int bkl_id){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            BookkeepersLiquidationRegister BKLiquidationReg = (BookkeepersLiquidationRegister) session.selectOne("BookkeepersLiquidationRegister.getById", bkl_id);
            return BKLiquidationReg;
        } finally {
            session.close();
        }
    }
    
    /**Returns a BookkeepersLiquidationRegister instance from the database
    public BookkeepersLiquidationRegister getAllPending(String status){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            BookkeepersLiquidationRegister BKLiquidationReg = (BookkeepersLiquidationRegister) session.selectOne("BookkeepersLiquidationRegister.getAllPending", status);
            return BKLiquidationReg;
        } finally {
            session.close();
        }
    }*/
 
    /**Updates an instance of BookkeepersLiquidationRegister in the database*/
    public void update(BookkeepersLiquidationRegister BKLiquidationReg){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.update("BookkeepersLiquidationRegister.update", BKLiquidationReg);
            session.commit();
        } finally {
            session.close();
        }
    }
    
    /**Updates the status of BookkeepersLiquidationRegister in the database
    public void updateStatus(int bkl_id){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.update("BookkeepersLiquidationRegister.updateStatus", bkl_id);
            session.commit();
        } finally {
            session.close();
        }
    }*/
 
    /** Insert an instance of BookkeepersLiquidationRegister into the database*/
    public void insert(BookkeepersLiquidationRegister BKLiquidationReg){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.insert("BookkeepersLiquidationRegister.insert", BKLiquidationReg);
            session.commit();
        } finally {
            session.close();
        }
    }
 
    /** Delete an instance of BookkeepersLiquidationRegister from the database*/
    public void delete(int bkl_id){
 
        SqlSession session = sqlSessionFactory.openSession();
 
        try {
            session.delete("BookkeepersLiquidationRegister.deleteById", bkl_id);
            session.commit();
        } finally {
            session.close();
        }
    }
}